package com.shanjupay.common.config;

import com.shanjupay.common.oss.QiNiuCloudClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p> 七牛云配置类 </p>
 *
 * @author <a href=mailto:zhaoboying@itcast.cn> byZhao </a>
 * @version 1.0.0
 * @motto Talk is cheap, show me the code!
 * @since 2022-05-02 17:46:00
 */
@Configuration
//@ConfigurationProperties会自动读取前缀 oss.qiniu 的nacos配置,会自动使用set方法进行注入
@ConfigurationProperties(prefix = "oss.qiniu")
public class QiNiuCloudOssConfig {
    private String url;
    private String accessKey;
    private String secretKey;
    private String bucket;
    /**
     * 初始化七牛云客户端到 spring容器
     * @return
     */
    @Bean
    public QiNiuCloudClient qiNiuCloudClient() {
        QiNiuCloudClient qiNiuCloudClient = new QiNiuCloudClient(this.accessKey, this.secretKey, this.bucket, this.url);
        return qiNiuCloudClient;
    }


    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getAccessKey() {
        return accessKey;
    }

    public void setAccessKey(String accessKey) {
        this.accessKey = accessKey;
    }

    public String getSecretKey() {
        return secretKey;
    }

    public void setSecretKey(String secretKey) {
        this.secretKey = secretKey;
    }

    public String getBucket() {
        return bucket;
    }

    public void setBucket(String bucket) {
        this.bucket = bucket;
    }
}
